package com.yy.job.console.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.google.common.base.Preconditions;
import com.yy.job.console.dto.JobLogView;
import com.yy.job.console.service.JobLogConsoleService;
import com.yy.job.console.utils.JobConsoleConstants;

@Controller
@RequestMapping({ JobConsoleConstants.YY_JOB_PREFIX })
public class YYJobPageController {
	
	@Autowired
	private JobLogConsoleService jobLogConsoleService;

	/**
	 * 控制台首页
	 * 
	 * @return
	 */
	@RequestMapping(value = "/jobListPage", method = RequestMethod.GET)
	public String home() {
		return "jobList";
	}

	/**
	 * 查询日志
	 * 
	 * @param jobId
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/logListPage", method = RequestMethod.GET)
	public String logListPage(@RequestParam("jobId") Long jobId, Map<String, Object> model) {
		Preconditions.checkArgument((jobId != null), "查询参数jobId不能为空");
		
		List<JobLogView> listJobLogs = jobLogConsoleService.listJobLogs(jobId);
		model.put("items", listJobLogs);

		return "logList";
	}
}
